package com.mrd.gtimp.business.entity;

import com.mrd.gtimp.base.entity.Company;
import com.mrd.gtimp.base.entity.User;

import org.hibernate.annotations.GenericGenerator;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity(name = "T_BIZ_BASE_BUSINESS_MODEL")
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.Entity(dynamicUpdate = true)
public abstract class BaseBusinessModel {

    @Id
    @GeneratedValue(generator = "paymentableGenerator")
    @GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
    @Column(name = "ID")
    private String id;

    /**
     * 发货人,真实托运人，从客户联系人列表获取
     */
    @ManyToOne
    @JoinColumn(name = "REAL_CUSTOMER_ID")
    private ContacterModel shipper;

    /**
     * 下单的客户公司/代理公司
     */
    @ManyToOne
    @JoinColumn(name = "CUSTOMER_COM_ID", updatable = false)
    private Company customer;

    @Column(updatable = false)
    private String creator;

    @Column(updatable = false)
    private Date ctime;

    private String modifier;

    private Date mtime;

    @Column(name = "BUSINESS_ID", updatable = false)
    private String businessId;

    @Column(name = "TYPE", updatable = false)
    private String type;

    /**
     * 业务供应商/业务代理人
     */
    @ManyToOne
    @JoinColumn(name = "SUP_ID")
    private Company supCompany;

    @Column(name = "R_SUP_ID")
    private String realSupId;

    /**
     * 业务系统主键信息，多主键用'-'间隔表示，次内容在客户下单后，业务数据提交到业务系统后，业务系统反馈会该键，如果该键不存在则下单不成功
     */
    @Column(name = "BPK")
    private String bpk;

    /**
     * 业务确认时间、下单时间
     */
    @Column(name = "CONFIRM_TIME")
    private Date confirmTime;
    /**
     * 业务审核通过时间
     */
    @Column(name = "VALIDATE_TIME")
    private Date validateTime;

    /**
     * 业务审核员信息拓展，若VALIDATE_ID字段为空，则填写该字段，可用于外部审核
     */
    @Column(name = "VALIDATOR_EXT")
    private String validator_ext;

    /**
     * 业务审核员
     */
    @ManyToOne
    @JoinColumn(name = "VALIDATOR_ID")
    private User validator;
    /**
     * 业务上传通过时间
     */
    @Column(name = "UPLOAD_TIME")
    private Date upload_time;

    /**
     * 业务上传员信息拓展，若UPLOADER_ID字段为空，则填写该字段，可用于外部上传
     */
    @Column(name = "UPLOADER_EXT")
    private String uploader_ext;

    /**
     * 业务上传员
     */
    @ManyToOne
    @JoinColumn(name = "UPLOADER_ID")
    private User uploader;
    /**
     * 业务上传通过时间
     */
    @Column(name = "FINISH_TIME")
    private Date finish_time;

    /**
     * 业务上传员信息拓展，若FINISHER_ID字段为空，则填写该字段，可用于外部上传
     */
    @Column(name = "FINISHER_EXT")
    private String finisher_ext;

    /**
     * 业务上传员
     */
    @ManyToOne
    @JoinColumn(name = "FINISHER_ID")
    private User finisher;

    @OneToMany
    @JoinColumn(name = "bid")
    private List<RejectContent> rejectContents;

    /**
     * 模板名称
     */
    @Column(name = "MODEL_NAME")
    private String model_name;

    /**
     * 保存模板时间
     */
    @Column(name = "SAVE_MODEL_TIME")
    private Date save_model_time;

    /**
     * 模板保存人
     */
    @ManyToOne
    @JoinColumn(name = "SAVE_MODEL_PERSON")
    private User save_model_person;

    /**
     * 录单类型
     * @return
     */
    @Column(name="ENTER_TYPE")
    private  String enter_type;
    @Column(name="AGENT_FOR_COM_ID")
    private String agent_for_com_id;
    @Column(name = "ENTER_PAGE")
    private String enter_page;
    @Column(name = "AGENT_NAME")
    private String agent_name;

    public void setAgent_name(String agent_name) {
        this.agent_name = agent_name;
    }

    public String getAgent_name() {
        return agent_name;
    }

    public void setEnter_page(String enter_page) {
        this.enter_page = enter_page;
    }

    public String getEnter_page() {
        return enter_page;
    }

    public String getAgent_for_com_id() {
        return agent_for_com_id;
    }

    public void setAgent_for_com_id(String agent_for_com_id) {
        this.agent_for_com_id = agent_for_com_id;
    }

    public String getEnter_type() {
        return enter_type;
    }

    public void setEnter_type(String enter_type) {
        this.enter_type = enter_type;
    }
    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public Date getMtime() {
        return mtime;
    }

    public void setMtime(Date mtime) {
        this.mtime = mtime;
    }

    public abstract BaseBusinessModel fromString(String businessString);

    @Override
    public abstract String toString();

    public Company getCustomer() {
        return customer;
    }

    public void setCustomer(Company customer) {
        this.customer = customer;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBusinessId() {
        return businessId;
    }

    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Company getSupCompany() {
        return supCompany;
    }

    public void setSupCompany(Company supCompany) {
        this.supCompany = supCompany;
    }

    public String getBpk() {
        return bpk;
    }

    public void setBpk(String bpk) {
        this.bpk = bpk;
    }

    public Date getUpload_time() {
        return upload_time;
    }

    public void setUpload_time(Date upload_time) {
        this.upload_time = upload_time;
    }

    public String getUploader_ext() {
        return uploader_ext;
    }

    public void setUploader_ext(String uploader_ext) {
        this.uploader_ext = uploader_ext;
    }

    public User getUploader() {
        return uploader;
    }

    public void setUploader(User uploader) {
        this.uploader = uploader;
    }

    public User getValidator() {
        return validator;
    }

    public void setValidator(User validator) {
        this.validator = validator;
    }

    public String getValidator_ext() {
        return validator_ext;
    }

    public void setValidator_ext(String validator_ext) {
        this.validator_ext = validator_ext;
    }

    public Date getFinish_time() {
        return finish_time;
    }

    public void setFinish_time(Date finish_time) {
        this.finish_time = finish_time;
    }

    public String getFinisher_ext() {
        return finisher_ext;
    }

    public void setFinisher_ext(String finisher_ext) {
        this.finisher_ext = finisher_ext;
    }

    public User getFinisher() {
        return finisher;
    }

    public void setFinisher(User finisher) {
        this.finisher = finisher;
    }

    /**
     * 清除自身业务数据主键的工具方法
     */
    public abstract void clearPk() throws Exception;

    public String getRealSupId() {
        return realSupId;
    }

    public void setRealSupId(String realSupId) {
        this.realSupId = realSupId;
    }

    public List<RejectContent> getRejectContents() {
        return rejectContents;
    }

    public void setRejectContents(List<RejectContent> rejectContents) {
        this.rejectContents = rejectContents;
    }

    public String getModel_name() {
        return model_name;
    }

    public void setModel_name(String model_name) {
        this.model_name = model_name;
    }

    public Date getSave_model_time() {
        return save_model_time;
    }

    public void setSave_model_time(Date save_model_time) {
        this.save_model_time = save_model_time;
    }

    public User getSave_model_person() {
        return save_model_person;
    }

    public void setSave_model_person(User save_model_person) {
        this.save_model_person = save_model_person;
    }

    public ContacterModel getShipper() {
        return shipper;
    }

    public void setShipper(ContacterModel shipper) {
        this.shipper = shipper;
    }

    public Date getConfirmTime() {
        return confirmTime;
    }

    public void setConfirmTime(Date confirmTime) {
        this.confirmTime = confirmTime;
    }

    public Date getValidateTime() {
        return validateTime;
    }

    public void setValidateTime(Date validateTime) {
        this.validateTime = validateTime;
    }
}
